package com.dl.pojo;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.List;

@ApiModel("分页")
@Component
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Page<T> implements Serializable {
    //页码
    private Integer currentPage;
    //页面大小
    private Integer pageSize;
    //数据总数
    private Integer total;
    //页面总数
    private Integer totalPage;
    //当前页面数据集合
    private List<T> list;
    //携带的消息
    private String msg;
/*    //统计信息
    private Map<Integer, Integer> count;*/


    //当我们调用 数据总数的set和页面大小的set后，自动计算出总页数
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
        this.totalPage = this.total % this.pageSize == 0 ? this.total / this.pageSize : this.total / this.pageSize + 1;
    }

}
